#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode() : val(0), left(nullptr), right(nullptr) {}
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
    TreeNode(int x, TreeNode* left, TreeNode* right) : val(x), left(left), right(right) {}
};

vector<int> largestValues(TreeNode* root) {
    if (root == nullptr)
        return vector<int>();

    vector<int> ret;
    queue<TreeNode*> que;

    que.push(root);

    while (!que.empty())
    {
        int tmp = INT_MIN;
        int size = que.size();

        for (int i = 0; i < size; ++i)
        {
            TreeNode* root = que.front();
            que.pop();

            tmp = max(tmp, root->val);

            if (root->left != nullptr)
                que.push(root->left);
            if (root->right != nullptr)
                que.push(root->right);
        }

        ret.push_back(tmp);
    }

    return ret;
}

int main()
{

	return 0;
}